home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Emulators / v2600 / Source.lha / Source / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-26  |  1.8 KB  |  88 lines

  1. /*****************************************************************************
  2.  
  3.    This file is part of x2600, the Atari 2600 Emulator
  4.    ===================================================
  5.    
  6.    Copyright 1996 Alex Hornby. For contributions see the file CREDITS.
  7.  
  8.    This software is distributed under the terms of the GNU General Public
  9.    License. This is free software with ABSOLUTELY NO WARRANTY.
  10.    
  11.    See the file COPYING for Details.
  12.  
  13.    Tweaked by Matthew Stroup for Amiga v2600, April 24, 1997.
  14.    
  15. ******************************************************************************/
  16.  
  17. /* 
  18.    The main program body.
  19.  */
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include "types.h"
  23. #include "display.h"
  24. // #include "keyboard.h"
  25. #include "realjoy.h"
  26. #include "files.h"
  27. #include "vmachine.h"
  28. #include "options.h"
  29. #include "sound.h"
  30.  
  31. /* The mainloop from cpu.c */
  32. extern void mainloop (void);
  33.  
  34. /* Make sure any exit() calls free up shared memory */
  35. void cleanup (void)
  36. {
  37. //  /* Close the raw keyboard */
  38. //  close_keyboard ();
  39.  
  40. //  /* Close the PC joystick */
  41. //  close_realjoy ();
  42.  
  43.   /* Close down display */
  44.   tv_off ();
  45.  
  46.   /* Turn off the sound */
  47.   sound_close ();
  48. }
  49.  
  50. /* The main entry point */
  51. /* argc: number of command line arguments */
  52. /* argv: the argument text */
  53. int main (int argc, char **argv)
  54. {
  55.   /* Parse options */
  56.   parse_options (argc, argv);
  57.  
  58.   /* Set up the cleanup code */
  59.   atexit (cleanup);
  60.  
  61.   /* Initialise the 2600 hardware */
  62.   init_hardware ();
  63.  
  64.   /* Turn the virtual TV on. */
  65.   tv_on (argc, argv);
  66.  
  67.   /* Turn on sound */
  68.   sound_init ();
  69.  
  70.   init_realjoy ();
  71.  
  72.   /* load cartridge image */
  73.   if (loadCart ())
  74.     {
  75.       fprintf (stderr, "Error loading cartridge image.\n");
  76.       exit (-1);
  77.     }
  78.  
  79.   /* Cannot be done until file is loaded */
  80.   init_banking();
  81.  
  82.   /* start cpu */
  83.   mainloop ();
  84.  
  85.   /* Thats it folks */
  86.   exit (0);
  87. }
  88.